Part Number Hot Search : 
R102M101 187AMS8E TK20D60U KTA701 75M00 2SK3466 TDA8102B IRS21
Product Description
Full Text Search
 

To Download AN4545 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  june 2014 docid026571 rev 1 1/27 AN4545 application note vl6180x basic rangin g application note introduction the vl6180x is a proximity sensor based on st?s patented flightsense? technology. the vl6180x interfaces to your micro-controller via the industry standard i2c bus. the module also includes an ambient light sensor (als). this application note describes how to set up the vl6180x and perform range measurements with the sensor. note: settings presented in this document are for test purpose only. performance and reliability not guaranteed. figure 1. vl6180x www.st.com
contents AN4545 2/27 docid026571 rev 1 contents 1 set-up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.1 powering the module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.2 communication with the vl6180x . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.3 initialisation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2 performing range measurements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.1 performing a range measurement in single-shot mode . . . . . . . . . . . . . . . 7 2.2 performing a range measurement in continuous mode . . . . . . . . . . . . . . . 7 3 other ranging outputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3.1 range error codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3.2 return array statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3.2.1 return signal rate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3.2.2 return convergence time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3.2.3 return signal count . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3.2.4 return ambient count . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3.3 reference array statistic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3.3.1 reference signal rate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3.3.2 reference convergence time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 3.3.3 reference signal count . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 3.3.4 reference ambient count . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 4 typical ranging output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 4.1 range output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11 4.1.1 manual offset calibration procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 4.2 signal rate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 4.3 convergence time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 5 cover glass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 5.1 range output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 5.1.1 cross ross talk calibration procedure . . . . . . . . . . . . . . . . . . . . . . . . . . 16 5.1.2 range ignore . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
docid026571 rev 1 3/27 AN4545 contents 27 6 device settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 6.1 performance tuning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 6.1.1 max convergence time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 6.1.2 inter-measurement period . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 6.1.3 readout averaging period . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 6.2 additional error checks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 7 example code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 8 acronyms and abbreviations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 9 sr03 settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 10 revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
set-up AN4545 4/27 docid026571 rev 1 1 set-up 1.1 powering the module to power the module, we recommend connecting a 2v8 supply to avdd and avdd_vcsel. avss and avss_vcsel mu st be connected to ground. note: gpio-0 is set as a shut down pin by defau lt hence must be pulled high to avoid shutting down the device. note: avdd_vcsel must be applied before or at the same time as avdd to ensure internal error check on the ir emitter passes. figure 2. vl6180x block diagram 1.2 communication with the vl6180x communication with the vl6180x is via the i2c bus. the default 7-bit address of the vl6180x is 0x29. it can be changed by the user to any 7-bit addresses by writing to the i2c_slave__device_address {0x212} regist er. the scl and sda lines should each have a pull-up resistor on the i2c bus. note: the vl6180x uses a 16-bit register index.
docid026571 rev 1 5/27 AN4545 set-up 27 1.3 initialisation the latest standard ranging (s r) settings must be loaded onto vl6180x after the device has powered up. the following is the recommended procedure for loading the settings into the vl6180x. 1. check device has powered up (optional) a) check system__fresh_out_of_reset {0 x16} register is equal to 0x01. 2. load settings onto vl6180x a) see section 9 for the settings. 3. apply other specific setti ngs e.g. cross talk, gpio, max convergence time etc. (optional) 4. write 0x00 to system__fresh_o ut_of_reset {0x16} (optional) a) help host determine if settings have been loaded. 5. vl6180x is ready to start a range measurement. note: this procedure must be repeated if the vl6 180x has been power cycled or if gpio-0 has been toggled. system__fresh_out_of_reset {0x16} will reset to 0x01 if the vl6180x has been power cycled or if gpio-0 was toggled. figure 3. initialisation steps device powerup check {0x16} is equal to 0x01 load settings onto vl6180x load other specific settings set {0x16} to 0x00 device ready for range measurement
performing range measurements AN4545 6/27 docid026571 rev 1 2 performing range measurements after the settings have been loaded, range measurements can be started in one of two modes, single-shot mode and continuous mode. in single-shot mode, the vl6180x will perfo rm a single range meas urement and will enter software standby once the measurement has completed. in continuous mode the vl6180x will perform back to back rang e measurements at a user determined rate until the stop command is issued. section 2.1 and section 2.2 outline the recommended procedure on performing a range measurements. section 7 contains example code on how to initialise the device and perform range measurements with the sensor. figure 4. flowchart for performing range measurements device ready for range measurement ranging mode start a ranging measurement. write 0x01 to {0x18} poll for new sample ready threshold event at {0x4f} read {0x62} for range result clear interrupt write 0x07 to {0x15} device ready for range measurement start range measurements. write 0x03 to {0x18} poll for new sample ready threshold event at {0x4f} read {0x62} for range result continue ranging? stop ranging. write 0x01 to {0x18} no yes single-shot clear interrupt write 0x07 to {0x15} continuous
docid026571 rev 1 7/27 AN4545 performing range measurements 27 2.1 performing a range meas urement in single-shot mode 1. check device is ready to start a range measurement. (optional) a) check bit 0 of result__range_status {0x4d} is set. 2. start a range measurement. a) write 0x01 to sysr ange__start {0x18}. 3. wait for range measurement to complete. a) poll result__interrupt_status_gpio {0x4 f} register till bit 2 is set to 1. (new sample ready threshold event). 4. reading range result. a) read result__range_val {0x62}. b) this is the range measurement between the vl6180x and target in mm 5. clear the interrupt status. a) write 0x07 to system__ interrupt_clear {0x15}. 6. repeat the previous steps 1 to 4 for more range measurements. 2.2 performing a range meas urement in continuous mode 1. check device is ready to start range measurement. (optional) 2. check bit 0 of result__range_status {0x4d} is set. 3. start range measurements. a) write 0x03 to sysr ange__start {0x18}. 4. wait for range measurement to complete. a) poll result__interrupt_status_gpio {0x4 f} register till bit 2 is set to 1. (new sample ready threshold event). 5. reading range result. a) read result__range_val {0x62}. b) this is the range measurement between the vl6180x and target in mm. 6. clear the interrupt status. a) write 0x07 to system__ interrupt_clear {0x15}. 7. repeat the steps 2 to 4 for more range measurements. 8. stop range measurements. a) write 0x01 to sysr ange__start {0x18}.
other ranging outputs AN4545 8/27 docid026571 rev 1 3 other ranging outputs as well as the range output, the following can also be read along with each range measurement. 3.1 range error codes register result__range_status {0x4d} returns an error code after each range measurement. table 13 gives a summary of the range error codes: table 1. range error codes 3.2 return array statistics 3.2.1 return signal rate register result__range_return_rate {0x66} contains the signal rate from the return array recorded during the range measurement. to convert the return rate into mcps, read {0x66} and divide the value by 128. note: {0x66} is a 16-bit register. bits [7:4] error code description range 0 no error valid measurement 0 - 200 (1) 1. range overflow occurs typically around 200 mm. 1-5 system error system error detected. no measurement possible. 255 6 early convergence estimate ece check failed 255 7 max convergence system did not converge before the specified max. convergence time limit no target detected 255 8 range ignore ignore threshold check failed 255 9-10 not used - - 11 snr ambient conditions too high. measurement invalidated 255 12 raw range algo underflow range < 0 (because offset is programmable a negative range result is possible) 0 13 raw range algo overflow result is out of range. this occurs typically around 200 mm 255 14 ranging algo underflow range < 0 (because offset is programmable a negative range result is possible) 0 15 ranging algo overflow result is out of range. this occurs typically around 200 mm 255
docid026571 rev 1 9/27 AN4545 other ranging outputs 27 3.2.2 return convergence time register result__range_return_ conv_time {0x7c} contains the time in s it took for the return array on vl6180x to settle or converge on a target distance during the range measurement. note: if return convergence time is equal to the max convergence time, then vl6180x was not able to detect a target during the last measurement. {0x7c} is a 32-bit register. 3.2.3 return signal count register result__range_return_vcsel_co unt {0x6c} contains the number of counts recorded during the convergence time (a) from the return array during the range measurement. the following equation show the relationship between count, signal rate and convergence time. note: {0x6c} is a 32-bit register. 3.2.4 return ambient count register result__range_return_amb_coun t {0x74} contains the number of ambient counts recorded during the convergence time (a) during the range measurement. the ambient counter is only active for 1/6th of the convergence time, hence the count value must be multiplied by 6. see the following equation of how to convert the ambient count into mcps. note: {0x74} is a 32-bit register 3.3 reference array statistic 3.3.1 reference signal rate register result__range_reference_rate {0x68} contains the signal rate from the reference array recorded during the range measurement. to convert the reference rate into mcps, read {0x68} and divide the value by 128. note: {0x68} is a 16-bit register. a. the count register continues to increment till both re turn and reference array have converged. this means for the convergence time [s], the maximum value betw een {0x7c} and {0x80} should be used in the equation. under normal operation, {0x7c} should be the larger number value. return signal rate [mcps] return signal count convergence time [s] ------------------- --------------------- --------------------- - = return ambient rate [mcps] return ambient count 6 convergence time [s] ------------------ ----------------- ------------------ --------------- - =
other ranging outputs AN4545 10/27 docid026571 rev 1 3.3.2 reference convergence time register result__range_reference_conv_tim e {0x80} contains the time in s it took for the reference array to settle or converged on a target distance during the range measurement. note: {0x7c} is a 32-bit register. 3.3.3 reference signal count register result__range_re ference_signal_count {0x70} contains the number of counts recorded during the convergence time (1) from the reference array during each range measurement. the following equation show the relationship between count, signal rate and convergence time. note: {0x70} is a 32-bit register. 3.3.4 reference ambient count register result__range_re ference_amb_count {0x78} contains the number of ambient counts recorded during the convergence time (1) from the reference array. the ambient counter is only active for 1/6 of t he convergence time, hence the count value must be multiplied by 6. see the following equation of how to convert the ambient count into mcps. note: {0x78} is a 32-bit register reference signal rate [mcps] reference signal count convergence time [s] ------------------ ------------------ ----------------- ---------- = reference ambient rate [mcps] reference ambient count 6 convergence time [s] --------------------- --------------------- ---------------------- -------------- =
docid026571 rev 1 11/27 AN4545 typical ranging output 27 4 typical ranging output 4.1 range output figure 5 shows the typical ranging output from vl6180x for different targets (b) at different distances. figure 5. graph of range output vs. target distance. the test was performed in the dark and with no cover glass. the range output of vl6180x with each of the targets should be linear with range. there could however be an offset error (c) . this error can be corrected by performing a manual offset calibration, see section 4.1.1 . note: at <10mm the interaction between the tar get and vl6180x will prev ent the range output from reaching 0mm. this is due to a number of physical effects: ? separation between vcsel and return array ? multiple reflections between target surface and vl6180x ? vcsel output penetrating the target surface and scattering off the layers inside the target b. munsell gray target. c. see section 4 in the vl6180x dataset for the spec on offset error.
typical ranging output AN4545 12/27 docid026571 rev 1 4.1.1 manual offset calibration procedure this section describes a procedure for calibrating offset. 1. clear the system offset a) write 0x00 to sysrange__part_to_part_range_offset {0x24}. 2. place a target at 50mm away from vl6180x. a) using a target with 17% reflectance or higher is recommended. b) when calibrating with cover glass we recommended using a target with reflectance of 88% or higher to minimise error from cross talk, cross 3. collect a number of range measurements with the target in place and calculate mean of the range results. a) for a reliable measurement, take at least 10 measurements. 4. calculate the offset required: 5. apply offset: a) write the calculated offset value to sysrange__part_to_part _range_offset {0x24}. note: {0x24} is in 2s complement representation. for offs et value 0 to127, write 0x00 to 0x7f. for offset value -1 to -128, wr ite 0xff to 0x80, e.g -30 = 0xe2 4.2 signal rate figure 6 shows the return signal rate output from vl6180x for different targets at different distances. the return signal rate can prov ide useful information on how optimised vl6180x settings to perform more efficiently and reliably. the return signal rate from a target will generally follow the inve rse square law as the target moves away from vl6180x. assume the ta rget fills the vl61 80x?s field of view (d) and is at a distance >10mm. as target distance drops below 10mm, the targ et will start to block off the optical path between the vcsel and the return array. a target at <10mm can reduce the signal to a level that can prevent the vl6180x from completing a range measurement. note: cover glass can alter the return signal rate characteristics. we therefore recommend the signal rate be re-characterized once the vl6180x has been integrated into the final system before attempting to perf orm any system optimisation. offset target distance [mm] average range [mm] ? = offset 50 average range [mm] ? = d. the field or view of vl6180x is approximately 12.5.
docid026571 rev 1 13/27 AN4545 typical ranging output 27 figure 6. graph of return signal rate vs. target distance. the test was performed in the dark and with no cover glass. 4.3 convergence time figure 7 shows the typical convergence time output from vl6180x for different targets at different distances. the convergence time can provide useful information on how to optimise vl6180x settings to perform more efficiently and reliably. note: cover glass can alter the return convergence time characteristics. we therefore recommend the convergence time be re-re-characterized once the vl6180x has been integrated into the final system before attempting to perform any system optimisation.
typical ranging output AN4545 14/27 docid026571 rev 1 figure 7. graph of convergence time vs. target distance. the test was performed in the dark and with no cover glass.
docid026571 rev 1 15/27 AN4545 cover glass 27 5 cover glass the vl6180x can be used with a cover glass. t he cover glass can cause internal reflection and this can be detected by vl6180x as unwant ed signals. this is known as the cross talk. the cross talk can affect the range output, hence we recommend the user perform the cross talk calibration procedure when using the vl6180x with cover glass (see section 5.1.1 ). the range ignore function should also be enabled to remove false detections from the cover glass, see section 5.1.2 . 5.1 range output figure 8 shows the impact of the cover glass on the range output of vl6180x. the internal reflection between the glass and the vl6180x causes the ranging output to decrease at longer distances. this error in range is a ratio of the target si gnal rate and magnitude of the cross talk, hence the range output from a darker target are more susceptible to the effect of cross talk. figure 9 shows the range output from vl6180x with the cross talk calibration procedure implemented. the range error caused by the cover glass is corrected. note: the offset might need to be re-calibrated when ranging though cover glass. the cross talk rate depends on the glass type and its placement relative to vl6180x. if the glass type or its position changes, then cross talk calibration might need to be re-done. figure 8. graph of range output vs. target distance without cross talk calibration. the test was performed in the dark and with cover glass
cover glass AN4545 16/27 docid026571 rev 1 figure 9. graph of range output vs. target distance with cross talk calibration. the test was performed in the dark and with cover glass 5.1.1 cross ross talk calibration procedure this section describes a procedure for calibrating system cross talk. 1. perform the offset calibration (recommended) a) see section 4.1.1 . note: if the offset is incorr ectly calibrated, cross talk calibration will be inaccurate. 2. place a dark target at 100mm away from vl6180x. a) low reflectance target recommended, e.g. 3% target. 3. ensure sysrange __crosstalk_compensation_r ate {0x1e} is set to 0. 4. collect a number of range measurements with the target in place and calculate mean of the range results and return signal rate. a) for a reliable measurement, take at least 10 measurements. 5. calculate the cross talk: 6. apply offset: a) write the calculated cross talk value to sysrange__crosstalk_comp ensation_rat e {0x1e}. note: {0x1e} is a 316-bit register in 9.7 format: for cross talk value of 0.4 mcps = 0.4 x 128 =51.2, register value to be written = 0x33. cross-talk [mcps] average rtn rate [mcps] 1 average range target distance --------------------- -------------------- - ? ?? ?? = cross-talk [mcps] rtn rate [mcps] 1 average range 100 ? ? () =
docid026571 rev 1 17/27 AN4545 cover glass 27 5.1.2 range ignore the range ignore function in vl6180x can be enabled by setting bit 1 of sysrange__range_check_enables {0x2d}. if enabled, the ignore threshold must be specified. we recommend setting the ignore threshold to at least 1.2x cross talk. e.g. sysrange__range_igno re_threshold {0x26} = cr oss talk (mcps) x 1.2 a range ignore error will be flagged if the return signal rate is less than the ignore threshold.
device settings AN4545 18/27 docid026571 rev 1 6 device settings 6.1 performance tuning changing the settings in this section can af fect the performance of the overall system. 6.1.1 max convergence time the sysrange__max_convergence_t ime {0x1c} register sets an upper limit for the max convergence time. see figure 10 . figure 10. system timing diagram fo r a signal ranging measurement the max convergence time is made up of th e convergence time and sampling period. by default the max convergence time is set to 49ms during device power-up. reducing the max convergence time will reduce the maximum time a measurement will be allowed to complete and can reduce the power consumption when no target is present. we recommend a value of 30ms for the max conver gence time as a suitable starting point. note: reducing the max convergence time will reduce the distance th e vl6180x is able to range to. since the max convergence time controls maximum duration of each range measurement, it effectively controls the minimum signal rate required by the vl6180x to complete a range measurement. during a range measurement, the signal from the return array is counted within the convergence time window. the vl6180x will only report an valid range when a threshold of 15360 has been reached. the minimum signal rate required for convergence is therefore related to the max convergence time via the following equation. the sampling period is set to 4.4ms by default. if the return signal from a target is lower th an the minimum signal rate then t he vl6180x will return a range output of 255 and a max convergence will be flagged. min signal rate [cps] 15360 max conv time [s] sampling period [s] ? ---------------------- --------------------- --------------------- --------------------- ------------------- - =
docid026571 rev 1 19/27 AN4545 device settings 27 note: {0x1c} is a 8-bit register. maximum value for the max convergence time is 63ms. minimum value should be set to a value of 2 or higher for range measurement to be successful. 1 code = 1 ms. 6.1.2 inter-measurement period the sysrange__intermeasureme nt_period {0x1b} regi ster sets the inter- measurement period between each measurement when in continuous mode. the inter- measurement period needs to be set to a value that is above the maximum allowable full ranging cycle period. the follo wing equations define the minimum inter-measurement period to ensure correct operation: inter-measurement period*0.9 > full ranging cycle = max convergence time + 5ms. note: {0x1b} is a 8-bit register. a value of 0x00 for {0x1b} equals to a inter-measurement period 10ms. each code will add 10ms to the inter-measurement period. e.g. inter-measurement period 50ms = 0x04. 6.1.3 readout averaging period the readout__averaging_sam ple_period {0x10a} register sets the internal readout averaging sample period. increasing the sampling period decreases noise but increases max convergence time and power consumption. each code corresponds to around 64.5s additional processing time and there is a fixed 1.3ms of overhead during readout. sampling period = 1.3ms + 64.5s * readout__averaging_sample_period by default {0x10a} is se t to 0x30 which will give a sampling period of 4.4ms. 6.2 additional error checks vl6180x has three additional system error checks which can be enabled to help filter out invalid range results. see the vl6180x data sheet on how to set these error checks as well as enabling and disabling them.
example code AN4545 20/27 docid026571 rev 1 7 example code below is example code on how to perform ra nging with vl6180x using single shot mode. the code is based on the stm32 f401 nucleo board and can be compiled using the mbed compiler. /////////////////////////////////////////////////////////////////// // beginning of code /////////////////////////////////////////////////////////////////// #include "mbed.h" serial pc ( serial_tx , serial_rx ); // set-up serial to pc i2c i2c ( i2c_sda , i2c_scl ); // set up i2c on the stm32 nucleo-401re #define addr (0x52) // i2c address of vl6180x shifted by 1 bit //(0x29 << 1) so the r/w command can be added /////////////////////////////////////////////////////////////////// // split 16-bit register address into two bytes and write // the address + data via i2c /////////////////////////////////////////////////////////////////// void writebyte ( wchar_t reg , char data ) { char data_write [ 3 ]; data_write [ 0 ] = ( reg >> 8 ) & 0xff ;; // msb of register address data_write [ 1 ] = reg & 0xff ; // lsb of register address data_write [ 2 ] = data & 0xff ; i2c . write ( addr , data_write , 3 ); } /////////////////////////////////////////////////////////////////// // split 16-bit register address into two bytes and write // required register address to vl6180x and read the data back /////////////////////////////////////////////////////////////////// char readbyte ( wchar_t reg ) { char data_write [ 2 ]; char data_read [ 1 ]; data_write [ 0 ] = ( reg >> 8 ) & 0xff ; // msb of register address data_write [ 1 ] = reg & 0xff ; // lsb of register address i2c . write ( addr , data_write , 2 ); i2c . read ( addr , data_read , 1 ); return data_read [ 0 ]; } /////////////////////////////////////////////////////////////////// // load settings
docid026571 rev 1 21/27 AN4545 example code 27 /////////////////////////////////////////////////////////////////// int vl6180x_init () { char reset ; reset = readbyte ( 0x016 ); if ( reset == 1 ){ // check to see has it be initialised already /////////////////////////////////////////////////////////////////// // added latest settings here - see section 8 /////////////////////////////////////////////////////////////////// writebyte ( 0x016 , 0x00 ); //change fresh out of set status to 0 } return 0 ; } /////////////////////////////////////////////////////////////////// // start a range measurement in single shot mode /////////////////////////////////////////////////////////////////// int vl6180x_start_range () { writebyte ( 0x018 , 0x01 ); return 0 ; } /////////////////////////////////////////////////////////////////// // poll for new sample ready ready /////////////////////////////////////////////////////////////////// int vl6180x_poll_range () { char status ; char range_status ; // check the status status = readbyte ( 0x04f ); range_status = status & 0x07 ; // wait for new measurement ready status while ( range_status != 0x04 ) { status = readbyte ( 0x04f ); range_status = status & 0x07 ; wait_ms ( 1 ); // (can be removed) } return 0 ; } /////////////////////////////////////////////////////////////////// // read range result (mm) /////////////////////////////////////////////////////////////////// int vl6180x_read_range () {
example code AN4545 22/27 docid026571 rev 1 int range ; range = readbyte ( 0x062 ); return range ; } /////////////////////////////////////////////////////////////////// // clear interrupts /////////////////////////////////////////////////////////////////// int vl6180x_clear_interrupts () { writebyte ( 0x015 , 0x07 ); return 0 ; } /////////////////////////////////////////////////////////////////// // main program loop /////////////////////////////////////////////////////////////////// int main () { int range ; // load settings onto vl6180x vl6180x_init (); while ( 1 ){ // start single range measurement vl6180x_start_range (); // poll the vl6180x till new sample ready vl6180x_poll_range (); // read range result range = vl6180x_read_range (); // clear the interrupt on vl6180x vl6180x_clear_interrupts (); // send range to pc by serial pc . printf ( "%d\r\n" , range ); wait ( 0.1 ); } } to change the example above to continuous mode: 1. in the vl6180x_start_range() function change the data written to vl6180x from 0x01 to 0x03. 2. in the while loop, move the function call for vl6180x_start_range() to outside the while loop, immediately after the vl6180x_init() call.
docid026571 rev 1 23/27 AN4545 acronyms and abbreviations 27 8 acronyms and abbreviations table 2. acronyms and abbreviations acronym/ abbreviation definition amb ambient convergence when the vl6180x have detect ed a target and ?converged? or acquired the target distance gpio general purpose input/output nvm non volatile memory mcps unit for measuring the signal rate from the return/reference array. mega-counts per second. snr signal-to-noise ratio sr standard ranging settings spad single photon avalanche diode vhv very high voltage
sr03 settings AN4545 24/27 docid026571 rev 1 9 sr03 settings below are the recommended settings required to be loaded onto the vl6180x during the initialisation of the device (see section 1.3 ). // mandatory : private registers writebyte ( 0x0207 , 0x01 ); writebyte ( 0x0208 , 0x01 ); writebyte ( 0x0096 , 0x00 ); writebyte ( 0x0097 , 0xfd ); writebyte ( 0x00e3 , 0x00 ); writebyte ( 0x00e4 , 0x04 ); writebyte ( 0x00e5 , 0x02 ); writebyte ( 0x00e6 , 0x01 ); writebyte ( 0x00e7 , 0x03 ); writebyte ( 0x00f5 , 0x02 ); writebyte ( 0x00d9 , 0x05 ); writebyte ( 0x00db , 0xce ); writebyte ( 0x00dc , 0x03 ); writebyte ( 0x00dd , 0xf8 ); writebyte ( 0x009f , 0x00 ); writebyte ( 0x00a3 , 0x3c ); writebyte ( 0x00b7 , 0x00 ); writebyte ( 0x00bb , 0x3c ); writebyte ( 0x00b2 , 0x09 ); writebyte ( 0x00ca , 0x09 ); writebyte ( 0x0198 , 0x01 ); writebyte ( 0x01b0 , 0x17 ); writebyte ( 0x01ad , 0x00 ); writebyte ( 0x00ff , 0x05 ); writebyte ( 0x0100 , 0x05 ); writebyte ( 0x0199 , 0x05 ); writebyte ( 0x01a6 , 0x1b ); writebyte ( 0x01ac , 0x3e ); writebyte ( 0x01a7 , 0x1f ); writebyte ( 0x0030 , 0x00 ); // recommended : public registers - see data sheet for more detail writebyte ( 0x0011 , 0x10 ); // enables polling for ?new sample ready? // when measurement completes writebyte ( 0x010a , 0x30 ); // set the averaging sample period // (compromise between lower noise and // increased execution time) writebyte ( 0x003f , 0x46 ); // sets the light and dark gain (upper // nibble). dark gain should not be // changed. writebyte ( 0x0031 , 0xff ); // sets the # of range measurements after // which auto calibration of system is // performed writebyte ( 0x0040 , 0x63 ); // set als integration time to 100ms
docid026571 rev 1 25/27 AN4545 sr03 settings 27 writebyte ( 0x002e , 0x01 ); // perform a single temperature calibration // of the ranging sensor optional: public registers - see data sheet for more detail writebyte ( 0x001b , 0x09 ); // set default ranging inter-measurement // period to 100ms writebyte ( 0x003e , 0x31 ); // set default als inter-measurement period // to 500ms writebyte ( 0x0014 , 0x24 ); // configures interrupt on ?new sample // ready threshold event?
revision history AN4545 26/27 docid026571 rev 1 10 revision history table 3. document revision history date revision changes 19-jun-2014 1 initial release.
docid026571 rev 1 27/27 AN4545 27 please read carefully: information in this document is provided solely in connection with st products. stmicroelectronics nv and its subsidiaries (?st ?) reserve the right to make changes, corrections, modifications or improvements, to this document, and the products and services described he rein at any time, without notice. all st products are sold pursuant to st?s terms and conditions of sale. purchasers are solely responsible for the choice, selection and use of the st products and services described herein, and st as sumes no liability whatsoever relating to the choice, selection or use of the st products and services described herein. no license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. i f any part of this document refers to any third party products or services it shall not be deemed a license grant by st for the use of such third party products or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoev er of such third party products or services or any intellectual property contained therein. unless otherwise set forth in st?s terms and conditions of sale st disclaims any express or implied warranty with respect to the use and/or sale of st products including without limitation implied warranties of merchantability, fitness for a parti cular purpose (and their equivalents under the laws of any jurisdiction), or infringement of any patent, copyright or other intellectual property right. st products are not designed or authorized for use in: (a) safety critical applications such as life supporting, active implanted devices or systems wi th product functional safety requirements; (b) aeronautic applications; (c) automotive applications or environments, and/or (d) aerospace applications or environments. where st products are not designed for such use, the purchaser shall use products at purchaser?s sole risk, even if st has been informed in writing of such usage, unless a product is expressly designated by st as being intended for ?automotive, automotive safety or medical? industry domains according to st product design specifications. products formally escc, qml or jan qualified are deemed suitable for use in aerospace by the corresponding governmental agency. resale of st products with provisions different from the statements and/or technical features set forth in this document shall immediately void any warranty granted by st for the st product or service described herein and shall not create or extend in any manner whatsoev er, any liability of st. st and the st logo are trademarks or registered trademarks of st in various countries. information in this document supersedes and replaces all information previously supplied. the st logo is a registered trademark of stmicroelectronics. all other names are the property of their respective owners. ? 2014 stmicroelectronics - all rights reserved stmicroelectronics group of companies australia - belgium - brazil - canada - china - czech republic - finland - france - germany - hong kong - india - israel - ital y - japan - malaysia - malta - morocco - philippines - singapore - spain - sweden - switzerland - united kingdom - united states of america www.st.com


▲Up To Search▲   

 
Price & Availability of AN4545

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X